package pt.iscte.pcd.project.remote;

import pt.iscte.pcd.project.exceptions.FileSystemException;
import pt.iscte.pcd.project.interfaces.EntryType;
import pt.iscte.pcd.project.interfaces.PCDDirectory;
import pt.iscte.pcd.project.interfaces.PCDFile;

public class RemoteFile extends RemoteEntry implements PCDFile {
	private static final long serialVersionUID = 1L;
	private int length;
	private byte[] contentFile;

	public RemoteFile(String fullPath, String fileName, PCDDirectory parent, int length, byte[] contentFile) {
		super(fullPath, fileName, EntryType.FILE, parent);
		this.setContentFile(contentFile);
		this.setLength(length);
	}

	@Override
	public int length() throws FileSystemException {
		return getLength();
	}

	@Override
	public byte[] read() throws FileSystemException {
		return getContentFile();
	}

	@Override
	public void write(byte[] dataToWrite) {
		setContentFile(dataToWrite);
	}

		public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public byte[] getContentFile() {
		return contentFile;
	}

	public void setContentFile(byte[] contentFile) {
		this.contentFile = contentFile;
	}

}
